package com.hshh.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hshh.util.ExcelUtil;

@Controller
public class ExcelDownloadController {

	@RequestMapping(value="/excelDownloadTest.file")
	public void getFileDownload(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		// TODO Auto-generated method stub
		String[] header = new String[5];
		header[0] = "id";
		header[1] = "name";
		header[2] = "path";
		header[3] = "in_date";
		header[4] = "money";
		
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		for(int i = 0 ; i < 5 ; i++){
			Map<String, Object> map = new HashMap<String, Object>();
			for(int j = 0 ; j < header.length ; j++){
				map.put(header[j], "a" + j + "" + j);
			}
			list.add(map);
		}
		
		ExcelUtil dzExcel = new ExcelUtil("age");
		dzExcel.setStartRow(3);
		dzExcel.setData(list);
		dzExcel.setHeader(header);
		dzExcel.writeExcel(response, "테스트_엑셀");
	}
}
